home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / Window Utilities / UMenuedWindows.h < prev    next >
Encoding:
Text File  |  1997-01-31  |  3.3 KB  |  95 lines  |  [TEXT/R*ch]

  1. // ===========================================================================
  2. //    File:                        UMenuedWindows.h
  3. // Version:                    1.0 - May 7, 1996
  4. //    Author:                    Mike Shields (mshields@inconnect.com)
  5. //                            
  6. //    Copyright ©1996 Mike Shields. All rights reserved.
  7. // ===========================================================================
  8. //    UMenuedWindows.cp        <- double-click + Command-D to see class declaration
  9. //
  10. // A set of classes which allow you to manage the dynamic portion of a Windows
  11. // menu in your application. These include the static class whcih does all of the
  12. // real work, an LAttachment class which manages the selection and hiliting of the
  13. // menu items, and a LWindow subclass which knows how to add and delete itself from
  14. // the menu
  15.  
  16. #pragma once
  17.  
  18. #include <PP_Types.h>
  19. #include <LAttachment.h>
  20. #include <LWindow.h>
  21.  
  22. class LArray;
  23.  
  24. //===========================================================================
  25. // UMenuedWindows
  26. //===========================================================================
  27. // This static class is the interface to the Windows menu. It handles adding
  28. // and deleting menu items which correspond to a window in your application
  29.  
  30. class UMenuedWindows
  31. {
  32.     friend class CMenuedWindowsAttachment;
  33.     
  34. public:
  35.     static void            InitMenuedWindows(Int16 inMENUid, LApplication* inApplication);
  36.  
  37.     static void            AddWindowToMenu(LWindow* inWindow);
  38.     static void            RemoveWindowFromMenu(LWindow* inWindow);
  39.  
  40.     static Int16        WindowToMenuItem(LWindow* inWindow);
  41.     static LWindow*    MenuItemToWindow(Int16 inMenuItem);
  42.     static void            SetCommandKey(LWindow* inWindow, char inKey);
  43.  
  44. private:
  45.     static ResIDT        sMenuID;
  46.     static Int16        sSeparatorPosition;
  47.     static LArray*        sWindowList;
  48.     
  49.     static void    GetMenuItemStatus(Int16 inMenuItem, Boolean &outEnabled, 
  50.                                             Boolean &outUsesMark, Char16 &outMark, 
  51.                                             StringPtr outName);
  52.     static void    SelectWindowMenuWindow(Int16 inMenuItem);
  53. };
  54.  
  55. //===========================================================================
  56. // CMenuedWindowsAttachment
  57. //===========================================================================
  58. // This class implements an attachment which gets attached to the application
  59. // and will filter events intended for the Windows menu. It handles enabling
  60. // and selecting of those items in the Windows menu corresponding to the 
  61. // windows which were dynamically added the the menu.
  62.  
  63. class CMenuedWindowsAttachment : public LAttachment
  64. {
  65. public:
  66.                         CMenuedWindowsAttachment(ResIDT inMenuID, Int16 inFirstItem);
  67.     virtual            ~CMenuedWindowsAttachment();
  68.     
  69. protected:
  70.     virtual void    ExecuteSelf(MessageT inMessage, void *ioParam);
  71.     
  72.     ResIDT            mMenuID;
  73.     Int16                mFirstItem;
  74. };
  75.  
  76. //===========================================================================
  77. // CMenuedWindow
  78. //===========================================================================
  79. // This class implements a window which automatically adds itself to the 
  80. // Windows menu.
  81.  
  82. class CMenuedWindow : public LWindow
  83. {
  84. public:
  85.     enum { class_ID = 'MnuD' };
  86.     static CMenuedWindow*
  87.                     CreateFromStream(LStream *inStream);
  88.                     CMenuedWindow();
  89.                     CMenuedWindow(const SWindowInfo &inWindowInfo);
  90.                     CMenuedWindow(ResIDT inWINDid, Uint32 inAttributes,
  91.                                         LCommander *inSuperCommander);
  92.                     CMenuedWindow(LStream *inStream);
  93.     virtual        ~CMenuedWindow();
  94. };
  95.